package com.fesine.quartz.chapter5;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;

/**
 * @description: 清除所有的jobDetail
 * @author: Fesine
 * @createTime:2016/11/19 22:46
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/11/19 22:46
 */
public class DeleteAllJobs {
    static Log logger = LogFactory.getLog(DeleteAllJobs.class);
    public static void main(String[] args) {
        try {
            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
            String[] groups = scheduler.getJobGroupNames();
            for (String group : groups) {
                String[] jobNames = scheduler.getJobNames(group);
                for (String jobName : jobNames) {
                    scheduler.deleteJob(jobName, group);
                    logger.info("任务："+jobName +" 被注销!");
                }
                logger.info("组："+group + " 被注销!");
            }
            scheduler.shutdown();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
}
